import 'package:flutter/material.dart';
import '../utils/icon.dart';
import './home.dart';
import './coffee.dart';
import './order.dart';
import './cart.dart';
import 'mine.dart';
import '../pages/caffee_pay.dart';
import '../pages/evaluate.dart';
class Entry extends StatefulWidget {

  Entry({Key key}):super(key:key);

  static var selectIndex = 0;

  @override
  State<StatefulWidget> createState() {
    return EntryState();
  }
}


class EntryState extends State<Entry> {
  Home home;

  final coffee = Coffee();
  final order = Order();
  final cart = Cart();
  final mine = Mine();


  List listPage;
  @override
  void initState() { 
    super.initState();
    home = Home(onPress:(){
      setState(() {
        Entry.selectIndex = 1;
      });
    });
    listPage = [home, coffee, order, cart, mine];
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title:"瑞幸咖啡页面仿写",
      theme: ThemeData(
        primarySwatch: Colors.red,
        primaryColor: Color.fromRGBO(144, 192, 239, 1.0),
      ),
      home: Scaffold(
        body:listPage[Entry.selectIndex],
        bottomNavigationBar:BottomNavigationBar(
          items: [
            BottomNavigationBarItem(icon: iconlogoNotText(size: 24.0), title: Text('首页')),
            BottomNavigationBarItem(icon: iconcaidan(size: 24.0), title: Text('菜单')),
            BottomNavigationBarItem(icon: iconorder(size: 24.0), title: Text('订单')),
            BottomNavigationBarItem(icon: icongouwuche(size: 24.0), title: Text('购物车')),
            BottomNavigationBarItem(icon: iconmine(size: 24.0), title: Text('我的')),
          ],
          onTap: (index){
            if (index != Entry.selectIndex) {
              setState(() {
                Entry.selectIndex = index;
              });
            }
          },
          currentIndex: Entry.selectIndex,
          selectedItemColor: Color.fromRGBO(43, 76, 126, 1),
          unselectedItemColor: Colors.grey,
          selectedFontSize: 12.0,
          unselectedFontSize: 12.0,
          showUnselectedLabels: true,
          type:BottomNavigationBarType.fixed
        )
      ),
      routes: {
        'payPage':(BuildContext context){
          return CoffeePay();
        },
        'evaluatePage':(BuildContext context) {
          return Evaluate();
        }
      },
    );
  }

}